package ONLINE_EXAM;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class hw_1 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int bottle;
        while ((bottle= Integer.valueOf(br.readLine()))  != 0){
            System.out.println(exchange(bottle));
        }

    }

    public static int exchange(int bottle){
        if (bottle <2){
            return 0;
        }
        if (bottle == 2){
            return 1;
        }

        int res = bottle/3+exchange(bottle/3 + bottle%3);

        return res;

    }

}
